<!-- Home -->
<template>
  <div>
    <Search></Search>
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in imageList" :key="item.id">
        <img v-lazy="`http://liufusong.top:8080${item.imgSrc}`" />
      </van-swipe-item>
    </van-swipe>
    <div class="home_container">
      <van-grid :border="false">
        <van-grid-item icon="wap-home-o" text="整租" />
        <van-grid-item icon="friends" text="合租" />
        <van-grid-item icon="map-marked" text="地图找房" />
        <van-grid-item icon="wap-home" text="出去租" to='/rent/add'/>
      </van-grid>
    </div>
    <div class="middle">
      <div class="xsTitle">
        <span>租房小组</span>
        <i>更多</i>
      </div>
      <van-grid direction="horizontal" :column-num="2" :gutter="10" :border="false">
        <van-grid-item class="GridItem" v-for="item in groupsList" :key="item.id">
          <template #icon>
            <img :src="`${imgSrc}+${item.imgSrc}`" class="ImgStyle">
          </template>
          <template #text>
            <div>
              <span>{{item.title}}</span>
              <span>{{item.desc}}</span>
            </div>
          </template>
        </van-grid-item>
      </van-grid>
    </div>
  </div>
</template>

<script>
import { swiperAPI, groupsAPI } from '@/api'
import Search from '@/components/Search.vue'
export default {
  components: {
    Search
  },
  data () {
    return {
      active: 0,
      imageList: [],
      groupsList: [],
      imgSrc: 'http://liufusong.top:8080'
    }
  },
  async created () {
    const res = await swiperAPI()
    // console.log(res)
    this.imageList = res.data.body
    const res2 = await groupsAPI()
    console.log(res2)
    this.groupsList = res2.data.body
  }
}
</script>
<style lang='less' scoped>
// 轮播图
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 200px;
}
.my-swipe .van-swipe-item img {
  height: 200px;
  width: 100%;
}
/deep/ .van-swipe {
  height: 200px;
}
//
/deep/ .van-grid-item__icon {
  font-size: 0.74667rem;
  background-color: #caebdb;
  width: 50px;
  height: 50px;
  text-align: center;
  line-height: 50px;
  border-radius: 50%;
  color: #58b67f;
}
/deep/ .van-grid-item__icon + .van-grid-item__text {
  margin-top: 0.21333rem;
  margin-top: 13px;
  color: #000;
  font-size: 15px;
}
//
.middle {
  background-color: #eff1f2;
  padding-bottom: 10px;
}
.xsTitle {
  display: flex;
  justify-content: space-between;
  padding: 10px 10px;
  text-align: center;
  vertical-align: middle;
  // margin-bottom: 8px;
}
.xsTitle span {
  font-size: 18px;
}
.xsTitle i {
  font-style: normal;
  font-size: 16px;
  color: #666;
}
.GridItem {
  border-radius: 20px;
}
.GridItem span {
  display: block;
  font-size: 13px;
  color: #666;
}
.ImgStyle {
  width: 70px;
  height: 70px;
  margin-right: 10px;
}
/deep/ .van-grid-item__content--horizontal {
    border-radius: 10px;
    border: none;
}
</style>
